import { message } from 'antd';

export const fieldLabelList = [
  {
    name: 'room_name',
    label: '场地名称',
    rules: [{ required: true, message: '请输入会场名称' }],
    placeholder: '请输入会场名称',
  }, {
    name: 'big',
    label: '场地类型',
    rules: [{ required: true, message: '请选择场地类型' }],
    placeholder: '请输入会场名称',
  }, {
    name: 'owner',
    label: '联系方式',
    rules: [{ required: true, message: '请选择管理员' }],
    placeholder: '请输入联系方式',
  }, {
    name: 'address',
    label: '所在位置',
    rules: [{ required: true, message: '请输入场地位置' }],
    placeholder: '请输入场地位置',
  }, {
    name: 'people',
    label: '容纳人数',
    rules: [{ required: true, message: '请输入容纳人数' }],
    placeholder: '请输入容纳人数',
  }, {
    name: 'price',
    label: '价格信息',
    rules: [{ required: true, message: '请输入价格信息' }],
    placeholder: '请输入价格信息',
  }, {
    name: 'item',
    label: '配套设施',
    rules: [{ required: true, message: '请输入配套设施信息' }],
    placeholder: '请输入配套设施信息',
  }, {
    name: 'label',
    label: '备注信息',
    rules: [{ required: true, message: '请输入备注信息' }],
    placeholder: '请输入备注信息',
  },
];

export const supportingList = [
  {
    name: 'WIFI',
    label: 'WIFI',
    value: 'WIFI',
    icon: 'wifi',
  }, {
    name: '长桌',
    label: '长桌',
    value: '长桌',
    icon: 'laptop',
  }, {
    name: '座椅',
    label: '座椅',
    value: '座椅',
    icon: 'laptop',
  }, {
    name: '讲台',
    label: '讲台',
    value: '讲台',
    icon: 'laptop',
  }, {
    name: '投影',
    label: '投影',
    value: '投影',
    icon: 'laptop',
  }, {
    name: '电视',
    label: '电视',
    value: '电视',
    icon: 'laptop',
  }, {
    name: '话筒',
    label: '话筒',
    value: '话筒',
    icon: 'laptop',
  }, {
    name: '灯光',
    label: '灯光',
    value: '灯光',
    icon: 'laptop',
  }, {
    name: '音箱',
    label: '音箱',
    value: '音箱',
    icon: 'laptop',
  },
];

export function getBase64(img, callback) {
  const reader = new FileReader();
  reader.addEventListener('load', () => callback(reader.result));
  reader.readAsDataURL(img);
}

export const beforeUpload = (file) => {
  const isJPG = file.type === 'image/jpeg' || file.type === 'image/png';
  if (!isJPG) {
    message.error('You can only upload JPG file!');
  }
  const isLt2M = file.size / 1024 / 1024 < 2;
  if (!isLt2M) {
    message.error('Image must smaller than 2MB!');
  }
  return isJPG && isLt2M;
};
